﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_GetParentLeader]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_GetParentLeader];
GO
CREATE PROCEDURE [dbo].[sproc_GetParentLeader]
    @TeamID int,
    @RightCode int
/*

============================================================
功能:    得到组的父组LEADER
参数:
    @TeamID int        :    组（类）ID
    @RightCode int        l    leader权代号

============================================================

*/
AS

SELECT * 
    FROM uds_staff 
    WHERE staff_id in (
            SELECT staff_id 
                FROM UDS_Assign_Rule 
                WHERE act_id = @rightcode and team_id = (
                                        SELECT ClassparentID 
                                            FROM uds_class 
                                            WHERE classid = @teamid
                                    ) 
                    and based_on = 4
            )